package com.smartdoc.mojo;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;

import com.power.doc.builder.OpenYapiBuilder;
import com.power.doc.model.ApiConfig;
import com.thoughtworks.qdox.JavaProjectBuilder;

@Execute(phase = LifecyclePhase.COMPILE)
@Mojo(name = "yapi", requiresDependencyResolution = ResolutionScope.COMPILE)
public class YapiMojo extends BaseDocsGeneratorMojo{

    @Override
    public void executeMojo(ApiConfig apiConfig, JavaProjectBuilder javaProjectBuilder)
        throws MojoExecutionException, MojoFailureException {
        try {
            OpenYapiBuilder.buildYapiCollection(apiConfig, javaProjectBuilder);
        } catch (Exception e) {
            getLog().error(e);
        }
    }

}
